/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package factorial;

import java.util.Scanner;

/**
 *
 * @author Valera
 */
public class Factorial
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.println("Enter number");
        Scanner sc = new Scanner(System.in);
        String number = sc.nextLine();
        int n;
        try
        {
            n = Integer.parseInt(number);
            String result_str = "Result: ";
            if (n >= 0)
            {
                long fuck_num = factorial(n);
                result_str = result_str + fuck_num;
            }
            else
            {
                result_str = result_str + "No result! You have entered negative number!!!!";
            }
            System.out.println(result_str);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

    }

    private static long factorial(int n)
    {
        if (n > 1)
        {
            return n * factorial(n - 1);
        }
        else
        {
            return 1;
        }
    }
}
